package com.itheima.reggie.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.reggie.entity.AddressBook;
import com.itheima.reggie.service.AddressBookService;
import com.itheima.reggie.dao.AddressBookDao;
import com.itheima.reggie.utils.ThreadLocalUtil;
import com.itheima.reggie.web.R;
import org.springframework.stereotype.Service;

/**
 * @author Wq
 * @description 针对表【address_book(地址管理)】的数据库操作Service实现
 * @createDate 2022-08-20 17:14:09
 */
@Service
public class AddressBookServiceImpl extends ServiceImpl<AddressBookDao, AddressBook>
        implements AddressBookService {

    /**
     * 新增地址
     *
     * @param addressBook
     * @return
     */
    @Override
    public R addAddressBook(AddressBook addressBook) {
        //获取当前登录用户
        Long userId = ThreadLocalUtil.getCurrentId();
        //添加实体中
        addressBook.setUserId(userId);
        this.save(addressBook);
        return R.success("新增地址成功");
    }


}




